package com.mycat.web.content;

import com.google.gson.GsonBuilder;
import org.springframework.web.servlet.view.AbstractView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
import java.util.Map;

/**
 * @author roger.
 * @email luojie@yzworld.cn
 * @date 2016/10/21
 */
public class JsonView extends AbstractView {
    @Override
    protected void renderMergedOutputModel(Map<String, Object> param, HttpServletRequest request, HttpServletResponse response) throws Exception {
        response.setContentType("application/json; charset=UTF-8");
        PrintWriter out = response.getWriter();
        out.write(new GsonBuilder().disableHtmlEscaping().create().toJson(param));
        out.close();
    }
}